﻿using IM.Easy.Core.Audit;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IM.Easy.Entity.Log
{
    /// <summary>
    /// 错误日志
    /// </summary>
    [SugarTable]
    public class SysExceptionLog : AuditableEntity<Guid>
    {
        /// <summary>
        /// 异常时间
        /// </summary>
        public DateTime Time { get; set; }

        /// <summary>
        /// 异常消息
        /// </summary>
        [SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
        public string Msg { get; set; }

        /// <summary>
        /// 堆栈跟踪
        /// </summary>
        [SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
        public string Trace { get; set; }

        /// <summary>
        /// 追踪id
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public string TraceIdentifier { get; set; }

        /// <summary>
        /// 附加信息
        /// </summary>
        [SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
        public string Info { get; set; }

        /// <summary>
        /// 异常类型
        /// </summary>
        public ExceptionEnum Type { get; set; }

        /// <summary>
        /// 追踪信息
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(TraceIdentifier), nameof(RequestTrackingLog.TraceIdentifier))]
        public RequestTrackingLog TraceInfo { get; set; }

    }

    /// <summary>
    /// 异常类型
    /// </summary>
    public enum ExceptionEnum
    {
        /// <summary>
        /// 系统异常
        /// </summary>
        System = 0,

        /// <summary>
        /// 业务异常
        /// </summary>
        Business = 1
    }
}
